package managementSys.library;
import java.util.ArrayList;
import java.util.Scanner;

import javax.management.modelmbean.ModelMBean;

import managementSys.library.BookModel;
import managementSys.library.BookcardModel;
public class LibraryFunction {
	public static void main(String[] args) {
		LibraryFunction ll = new LibraryFunction();
		ll.start();
	}
	Scanner sc = new Scanner(System.in);
	ArrayList<BookcardModel> bookcardlist = new ArrayList<BookcardModel>();
	ArrayList<BookModel> booklist = new ArrayList<BookModel>();
	public void start() {
		while(true) {
			System.out.println("=========欢迎进入中享思途图书馆==========");
			System.out.println("----------请选择你需要的功能------------");
			System.out.println("-----1.进书--------------------------");
			System.out.println("-----2.办卡--------------------------");
			System.out.println("-----3.借书--------------------------");
			System.out.println("-----4.还书--------------------------");
			System.out.println("-----5.查询书的借出记录-----------------");
			System.out.println("-----6.查询卡的借书记录-----------------");
			System.out.println("-----7.显示书目排行榜------------------");
			System.out.println("=====0.退出系统=======================");
			System.out.println("====================================");
			switch (Integer.parseInt(sc.nextLine())) {
			case 1:
				inputs();
				break;
			case 2:
				applyCard();
				break;
			case 3:
				break;
			case 4:
				break;
			case 5:
				break;
			case 6:
				break;
			case 7:
				break;
			case 0:
				break;
			}
		}
	}
	public void input() {
		BookModel model = new BookModel();
		System.out.println("请输入要添加的书号：");
		String ss = sc.nextLine();

		do {
			//先输入决定性变量
			System.out.println("请输入书号");
			ss = sc.nextLine();
		}while(isExist(ss));
		model.setBookid(ss);
		System.out.println("请输入书名字：");
		model.setBookname(sc.nextLine());
		model.setBorrowtime(0);		//初始化书的借出次数为0
		
	}
	public boolean isExist(String i) {
		for(BookModel m:booklist) {
			if(m.getBookid().equals(i))
				System.out.println("该书已存在");
				return true;
		}
		return false;
	}
	public void inputs() {
		while(true) {
			input();
			System.out.println("是否继续输入？Y/N");
			if("Y".equalsIgnoreCase(sc.nextLine()))
				continue;
		}
	}
	
	public void applyCard() {
		BookcardModel model = new BookcardModel();
		System.out.println();
	}
}
